<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>vpow_i</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="vpow.html" title="vpow" />
    <link rel="next" href="vpowv.html" title="vpowv" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">vpow_i</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="vpow.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="vpowv.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="vpow_i"></a>
      <div class="titlepage"></div>
      <a id="IndexVpow_i" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">vpow_i</span>
        </h2>
        <p>vpow_i — 
     Raises each element of a vector to a scalar power
    </p>
      </div>
      <div class="refsect1">
        <a id="idp165659680"></a>
        <h2>Description</h2>
        <p>
     Raises each element of a vector to a scalar power
    </p>
      </div>
      <div class="refsect1">
        <a id="idp165661008"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>vpow_i</strong></span>  ifn, ival, ielements [, idstoffset]</pre>
      </div>
      <div class="refsect1">
        <a id="idp165663104"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifn</em></span>  - number of the table hosting the vectorial signal to be processed
    </p>
        <p>
      <span class="emphasis"><em>ielements</em></span> - number of elements of the vector
    </p>
        <p>
      <span class="emphasis"><em>ival</em></span> - scalar value to which the elements of ifn will be raised
    </p>
        <p>
      <span class="emphasis"><em>idstoffset</em></span> - index offset for the destination table
    </p>
      </div>
      <div class="refsect1">
        <a id="idp165667616"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>vpow_i</em></span> elevates each element of the vector contained in the table <span class="emphasis"><em>ifn</em></span> to the power of <span class="emphasis"><em>ival</em></span>, starting from table index <span class="emphasis"><em>idstoffset</em></span>. This enables you to process a specific section of a table by specifying the offset and the number of elements to be processed. Offset is counted starting from 0, so if no offset is specified (or set to 0), the table will be modified from the beginning.
    </p>
        <p>
      This opcode runs only on initialization, there is a k-rate version of this opcode called <a class="link" href="vpow.html" title="vpow"><em class="citetitle">vpow</em></a>.
    </p>
        <p>
      Negative values for <span class="emphasis"><em>idstoffset</em></span> are valid. Elements from the vector that are outside the table, will be discarded, and they will not wrap around the table.
    </p>
        <p>
      In all these opcodes, the resulting vectors are stored in <span class="emphasis"><em>ifn</em></span>, overriding the intial vectors. If you want to keep initial vector, use <a class="link" href="vcopy.html" title="vcopy"><em class="citetitle">vcopy</em></a> or <a class="link" href="vcopy_i.html" title="vcopy_i"><em class="citetitle">vcopy_i</em></a> to copy it in another table. All these operators are designed to be used together with other opcodes that operate with vectorial signals such as <a class="link" href="vcella.html" title="vcella"><em class="citetitle">vcella</em></a>, <a class="link" href="adsynt.html" title="adsynt"><em class="citetitle">adsynt</em></a>, <a class="link" href="adsynt2.html" title="adsynt2"><em class="citetitle">adsynt2</em></a>, etc.  They can also be useful in conjunction with the spectral opcodes <a class="link" href="pvsftw.html" title="pvsftw"><em class="citetitle">pvsftw</em></a> and <a class="link" href="pvsftr.html" title="pvsftr"><em class="citetitle">pvsftr</em></a>.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp165681440"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the vpow_i opcode. It uses the file <a class="ulink" href="examples/vpow_i.csd" target="_top"><em class="citetitle">vpow_i.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp165683296"></a>
          <p class="title">
            <strong>Example 1015. Examples of the vpow_i opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in</span>
-odac           -iadc     <span class="comment">;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o cigoto.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span><span class="op">=</span>44100
<span class="ohdr">ksmps</span><span class="op">=</span>128
<span class="ohdr">nchnls</span><span class="op">=</span>2

	<span class="oblock">instr</span> 1
ifn1 <span class="op">=</span> p4
ival <span class="op">=</span> p5
ielements <span class="op">=</span> p6
idstoffset <span class="op">=</span> p7
kval <span class="opc">init</span> 25
<span class="opc">vpow_i</span> ifn1, ival, ielements, idstoffset
	<span class="oblock">endin</span>

	<span class="oblock">instr</span> 2	<span class="comment">;Printtable</span>
itable <span class="op">=</span> p4
isize <span class="op">=</span> <span class="opc">ftlen</span>(itable)
kcount <span class="opc">init</span> 0
kval <span class="opc">table</span> kcount, itable
<span class="opc">printk2</span> kval

<span class="octrl">if</span> (kcount <span class="op">==</span> isize) then
  <span class="opc">turnoff</span>
<span class="octrl">endif</span>

kcount <span class="op">=</span> kcount <span class="op">+</span> 1 
	<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">f</span> 1 0 16 -7 1 16 17

<span class="stamnt">i</span>2	0.0	0.2	1
<span class="stamnt">i</span>1	0.4	0.01	1	2	3	4
<span class="stamnt">i</span>2	0.8	0.2	1
<span class="stamnt">i</span>1	1.0	0.01	1	0.5	5	-3
<span class="stamnt">i</span>2	1.2	0.2	1
<span class="stamnt">i</span>1	1.4	0.01	1	1.5	10	12
<span class="stamnt">i</span>2	1.6	0.2	1
<span class="stamnt">e</span>

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      Here is another example of the vpow_i opcode. It uses the file <a class="ulink" href="examples/vpow_i-2.csd" target="_top"><em class="citetitle">vpow_i-2.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp165688576"></a>
          <p class="title">
            <strong>Example 1016. </strong>
          </p>
          <div class="example-contents">
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o vpow_i-2.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

gifil <span class="ohdr">ftgen</span> 1, 0, 0, 1, "fox.wav", 0, 0, 1

<span class="oblock">instr</span> 1

ival       <span class="op">=</span> p4				<span class="comment">;different distortion settings</span>
ielements  <span class="op">=</span> p5
idstoffset <span class="op">=</span> p6				<span class="comment">;index offset</span>
<span class="opc">vpow_i</span> 1, ival, ielements, idstoffset
asig <span class="opc">lposcil</span> 1, 1, 0, 0, 1
     <span class="opc">outs</span> asig, asig

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
	
<span class="stamnt">i</span>1	0	2.7	.5	70000	0	<span class="comment">;no offset</span>
<span class="stamnt">i</span>1	3	2.7	.01	50000	70000	<span class="comment">;add another period of distortion, starting at sample 70000	</span>

<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp165690064"></a>
        <h2>See also</h2>
        <p>
      <a class="link" href="vadd_i.html" title="vadd_i"><em class="citetitle">vadd_i</em></a>, <a class="link" href="vmult_i.html" title="vmult_i"><em class="citetitle">vmult_i</em></a>, <a class="link" href="vpow.html" title="vpow"><em class="citetitle">vpow</em></a> and <a class="link" href="vexp_i.html" title="vexp_i"><em class="citetitle">vexp_i</em></a>.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp165694992"></a>
        <h2>Credits</h2>
        <p>Written by Gabriel Maldonado. Optional arguments added by Andres Cabrera and Istvan Varga.</p>
        <p>New in Csound 5 (Previously available only on CsoundAV)</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="vpow.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="vpowv.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">vpow </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> vpowv</td>
        </tr>
      </table>
    </div>
  </body>
</html>
